
local template = require("mvc.ext.template")
local resp = require("mvc.resp");

local _M = {};

function _M.to_error(err_msg_content, err_msg_item, exception)
	if err_msg_item == nil then
		err_msg_item = "";
	end
	template.caching(true)
	local func = template.compile("../mvc/view/error/hades-errors.html");
	local template_context = {};
	
	for i = 1, #err_msg_item, 1 do
		err_msg_content = string.gsub(err_msg_content, "{" .. i .. "}", err_msg_item[i]);
	end
	
	template_context["err_msg_content"] = err_msg_content;
	template_context["exception"] = exception;
	
	local content = func(template_context);
	resp.set_content_type("text/html;charset=utf-8").out(content);
end

return _M;

